/*
 * bluetooth.h
 *
 *  Created on: 2012.11.27.
 *      Author: Peter
 */

#ifndef BLUETOOTH_H_
#define BLUETOOTH_H_

#define NUMBER_OF_TESTVARS 16
#define PACKET_SIZE 2
#define RX_BUFFER_SIZE NUMBER_OF_TESTVARS*PACKET_SIZE
#define MAX_MSG_LEN 8

/* Reception state macros*/
#define BT_WAITFOR_START 0
#define BT_GET_ADDR      1
#define BT_GET_MSG_LEN   2
#define BT_GET_MSG_DATA      3

typedef struct
{
	uint32_t addr;
	uint8_t len;
	uint8_t data[8];
	uint8_t valid;
} BluetoothBufferType;

void Init_Bluetooth(void);
void Init_BluetoothNotUsed(void);
uint8_t SendDataToBT(uint16_t data);
void USART3_IRQHandler(void);


extern uint8_t tx_buffer[50];
extern uint8_t in_buffer[RX_BUFFER_SIZE];
extern uint8_t BT_rx_packnum;
extern uint8_t BT_Rx_Phase;
extern uint8_t BT_data_len;
extern uint8_t BT_data_counter;
extern uint8_t BT_tx_pack_part;
extern uint8_t BT_addr_counter;
extern uint8_t to_send;
extern BluetoothBufferType rx_buffer[20];

#endif /* BLUETOOTH_H_ */

